export default {
    data() {
        return {
            sex_option: {}
        }
    },
    mounted() {
        var gender_data = [
            { name: "北京市", men: 5389072, women: 5266804 },
            { name: "天津市", men: 2634473, women: 2593944 },
            { name: "河北省", men: 11355691, women: 11346545 },
            { name: "山西省", men: 5152643, women: 5067070 },
            { name: "内蒙古", men: 2712686, women: 2603282 },
            { name: "辽宁省", men: 7560804, women: 7592155 },
            { name: "吉林省", men: 3664268, women: 3716538 },
            { name: "黑龙江省", men: 4657780, women: 4710413 },
            { name: "上海市", men: 3782349, women: 3546863 },
            { name: "江苏省", men: 8689674, women: 8600106 },
            { name: "浙江省", men: 6932343, women: 6747680 },
            { name: "安徽省", men: 6485107, women: 6579507 },
            { name: "福建省", men: 4825326, women: 4698906 },
            { name: "江西省", men: 5114547, women: 5162727 },
            { name: "山东省", men: 10238272, women: 10298846 },
            { name: "河南省", men: 12162644, women: 12208763 },
            { name: "湖北省", men: 6217624, women: 6338487 },
            { name: "湖南省", men: 6972175, women: 7000306 },
            { name: "广东省", men: 10384305, women: 10057161 },
            { name: "广西", men: 4645693, women: 4663469 },
            { name: "海南省", men: 1249387, women: 1285092 },
            { name: "重庆市", men: 6311028, women: 6301907 },
            { name: "四川省", men: 10611062, women: 10556015 },
            { name: "贵州省", men: 4158276, women: 4188191 },
            { name: "云南省", men: 5419414, women: 5384454 },
            { name: "西藏", men: 601916, women: 579145 },
            { name: "陕西省", men: 5769343, women: 5761571 },
            { name: "甘肃省", men: 3426757, women: 3408358 },
            { name: "青海省", men: 738871, women: 715153 },
            { name: "宁夏", men: 1293875, women: 1283173 },
            { name: "新疆", men: 8578767, women: 8186213 },
            { name: "香港", men: 202296, women: 169084 },
            { name: "澳门", men: 29067, women: 26665 },
            { name: "台湾", men: 102897, women: 54989 },
        ];
        var provinces = gender_data.map(data => data.name);
        var menData = gender_data.map(data => data.men);
        var womenData = gender_data.map(data => data.women);
        this.sex_option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            legend: {},
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'value',
                boundaryGap: [0, 0.01],
                axisLabel: {
                    formatter: function (value) {
                        // 将值转换为以万为单位的整数显示
                        return Math.floor(value / 10000) + '万';
                    },
                    textStyle: {
                        color: '#FFFFFF' // 设置标签颜色为白色
                    }
                }
            },
            yAxis: {
                type: 'category',
                boundaryGap: [0, 0.01],
                axisLabel: {
                    textStyle: {
                        color: '#FFFFFF' // 设置标签颜色为白色
                    }
                },
                data: provinces
            },
            series: [
                {
                    name: '男性',
                    type: 'bar',
                    data: menData
                },
                {
                    name: '女性',
                    type: 'bar',
                    data: womenData
                }
            ],
        };

    }
}